package com.kaizzi.data.jdl.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kaizzi.data.common.been.TempBeen;
import com.kaizzi.data.common.been.UserDetailBeen;
import com.kaizzi.data.jdl.entity.CrmMember;
import com.kaizzi.data.jdl.mapper.CrmMemberMapper;
import com.kaizzi.data.jdl.service.CrmMemberService;
import com.kaizzi.data.jdl.service.JdlNumService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Kzen
 * @Description description
 * @date 2020/9/10
 */
@Service
@Slf4j
public class CrmMemberServiceImpl extends ServiceImpl<CrmMemberMapper, CrmMember> implements CrmMemberService {

    @Resource
    private CrmMemberMapper crmMemberMapper;
    @Resource
    private JdlNumService jdlNumService;

    @Override
    @DS("jdl_view")
    public long getUserCount(String startDate,String endDate,String utc) {
        Long userCount = crmMemberMapper.getUserCount(startDate, endDate, utc);
        return jdlNumService.transNum(userCount);
    }

    @Override
    @DS("jdl_view")
    public long getKing(String startDate, String endDate) {
        Long king = crmMemberMapper.getKing(startDate, endDate);
        return jdlNumService.transNum(king);
    }

    @Override
    @DS("jdl_view")
    public long getWes(String startDate, String endDate) {
        Long wes = crmMemberMapper.getWes(startDate, endDate);
        return jdlNumService.transNum(wes);
    }

    @Override
    @DS("jdl_view")
    public long getTeamCount(String startDate, String endDate) {
        Long teamCount = crmMemberMapper.getTeamCount(startDate, endDate);
        return jdlNumService.transNum(teamCount);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getAgeDistribute(String startDate, String endDate) {
        return crmMemberMapper.getAgeDistribute(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getGenderDistribute(String startDate, String endDate) {
        return crmMemberMapper.getGenderDistribute(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getAreaDistribute(String startDate, String endDate) {
        return crmMemberMapper.getAreaDistribute(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getVip(String startDate, String endDate) {
        return crmMemberMapper.getVip(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public long getRegistUser(String startDate, String endDate) {
        Long registUser = crmMemberMapper.getRegistUser(startDate, endDate);
        return jdlNumService.transNum(registUser);
    }

    @Override
    @DS("jdl_view")
    public long getOldUser(String startDate, String endDate) {
        Long oldUser = crmMemberMapper.getOldUser(startDate, endDate);
        return jdlNumService.transNum(oldUser);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getUtcGender(String startDate, String endDate) {
        return crmMemberMapper.getUtcGender(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getUtcAge(String startDate, String endDate) {
        return crmMemberMapper.getUtcAge(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getUtcArea(String startDate, String endDate) {
        return crmMemberMapper.getUtcArea(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public long getTeamUser(String startDate, String endDate) {
        Long teamUser = crmMemberMapper.getTeamUser(startDate, endDate);
        return jdlNumService.transNum(teamUser);
    }

    @Override
    @DS("jdl_view")
    public long getTeamNewUser(String startDate, String endDate) {
        Long teamNewUser = crmMemberMapper.getTeamNewUser(startDate, endDate);
        return jdlNumService.transNum(teamNewUser);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getLastSportTypeCount(String startDate, String endDate) {
        return crmMemberMapper.getLastSportTypeCount(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getLastSportStatusCount(String startDate, String endDate) {
        return crmMemberMapper.getLastSportStatusCount(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getTeamDemand(String startDate, String endDate) {
        return crmMemberMapper.getTeamDemand(startDate,endDate);
    }

    @Override
    @DS("jdl_view")
    public List<UserDetailBeen> getCrmUserDetail(String mopenId) {
        return crmMemberMapper.getCrmUserDetail(mopenId);
    }

    @Override
    @DS("jdl_view")
    public long getRegistUser2(String startDate, String endDate) {
        long registUser2 = crmMemberMapper.getRegistUser2(startDate, endDate);
        return jdlNumService.transNum(registUser2);
    }

    @Override
    @DS("jdl_view")
    public long getOldUser2(String startDate, String endDate) {
        long oldUser2 = crmMemberMapper.getOldUser2(startDate, endDate);
        return jdlNumService.transNum(oldUser2);
    }

    @Override
    @DS("jdl_view")
    public long getTeamNewUser2(String startDate, String endDate) {
        long teamNewUser2 = crmMemberMapper.getTeamNewUser2(startDate, endDate);
        return jdlNumService.transNum(teamNewUser2);
    }

    @Override
    @DS("jdl_view")
    public long getTeamOldUser2(String startDate, String endDate) {
        long teamOldUser2 = crmMemberMapper.getTeamOldUser2(startDate, endDate);
        return jdlNumService.transNum(teamOldUser2);
    }

    @Override
    @DS("jdl_view")
    public List<TempBeen> getClubUser(String startDate, String endDate) {
        return crmMemberMapper.getClubUser(startDate,endDate);
    }


    //----------------------分割线----------------------------------

    @Override
    @DS("jdl_view")
    public List<CrmMember> findAll() {
        return crmMemberMapper.findAll();
    }
}
